<?php
/**
 * Created by PhpStorm.
 * User: luxuewen_gz
 * Mail: lu.xuewen@qq.com
 * Date: 2018/12/5
 * Time: 9:21
 * //
 * //                            _ooOoo_
 * //                           o8888888o
 * //                           88" . "88
 * //                           (| -_- |)
 * //                           O\  =  /O
 * //                        ____/`---'\____
 * //                      .'  \\|     |//  `.
 * //                     /  \\|||  :  |||//  \
 * //                    /  _||||| -:- |||||-  \
 * //                    |   | \\\  -  /// |   |
 * //                    | \_|  ''\---/''  |   |
 * //                    \  .-\__  `-`  ___/-. /
 * //                  ___`. .'  /--.--\  `. . __
 * //               ."" '<  `.___\_<|>_/___.'  >'"".
 * //              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 * //              \  \ `-.   \_ __\ /__ _/   .-` /  /
 * //         ======`-.____`-.___\_____/___.-`____.-'======
 * //                            `=---='
 * //        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 * //                      佛祖保佑       永无BUG
 */

namespace app\admin\controller;


use think\captcha\Captcha;
use think\Controller;

class Login extends Controller
{
    /**
     * 登录页面
     * @return mixed
     */
    public function index(){
        return $this->fetch();
    }

    /**
     * 验证码
     * @return \think\Response
     */
    public function verify(){
        $config =    [
            'fontSize'    =>    30,
            'length'      =>    4,
            'useNoise'    =>    true,
        ];
        $captcha = new Captcha($config);
//        $captcha->useZh = true;
//        $captcha->zhSet = '甲乙丙丁戊己庚辛壬癸子丑寅卯辰巳午未申酉戌亥';
        return $captcha->entry();
    }
    public function loginSubmit(){
        $data = [
            'username'      =>  $this->request->post('username'),
            'password'      =>  $this->request->post('password'),
            'verify_code'   =>  $this->request->post('verify_code')
        ];
        $res = model('Login', 'logic')->loginSubmit($data);
        return $res;
    }
    public function loginOut(){
        model('Login', 'logic')->loginOut();
        $this->success('已退出登录！', '/admin-login');
    }


}